package org.lex.net.ftp.parser;

import org.lex.net.ftp.FTPFile;
import org.lex.utils.CategoryComparator;

/**
 * 1. first put directory before file 2. then sort by name
 */
public class FTPFileNameComparator implements CategoryComparator<FTPFile> {
	@Override
	public int getCategory(FTPFile file) {
		if (true == file.isDirectory())
			return 0;
		else
			return 1;
	}

	public int compare(FTPFile e1, FTPFile e2) {
		return e1.getName().compareTo(e2.getName());
	}
}
